package com.lej.dataservice.club.http.interceptor

import okhttp3.Interceptor
import okhttp3.Response
import java.io.IOException

class BaseInterceptor(private val headers: Map<String, String>?) : Interceptor {
    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        val builder = chain.request().newBuilder()
        headers?.takeIf { headers.isNotEmpty() }?.keys?.map { headerKey ->
            builder.addHeader(headerKey, headers.getValue(headerKey)).build()
        }
//        if (headers != null && headers.isNotEmpty()) {
//            val keys = headers.keys
//            for (headerKey in keys) {
//                builder.addHeader(headerKey, headers.getValue(headerKey)).build()
//            }
//        }
        //请求信息
        return chain.proceed(builder.build())
    }

}